function changeColorInfo(color)
{
    $('#color').val(color);

    if ($('#sexRadio').is(':checked'))
    {
        $('.bigImgShirt').css('background-image', 'url(img/backshirts/big-' + color + '.png)');
    }
    else
    {
        $('.bigImgShirt').css('background-image', 'url(img/backshirts/big-' + color + '-girl.png)');
    }
	updateDisponibility();
}

function updateInfo()
{
    changeColorInfo($('#color').val());
}

function updateDisponibility()
{
	$('#dispo').html('-');
	$('#buyButton').attr('disabled','disabled');
	jQuery.ajax({
		type: 'GET',
		url: 'pages/controller/ajax/disponibility.php',
		data: {
			id: $('#id').val(),
			color: $('#color').val(),
			sex: ($('#sexRadio').is(':checked'))?'H':'F',
			size: $('#size').val()
		},
		
		success: function(data, textStatus, jqXHR) {
			
			if(data > 0)
			{
				$('#buyButton').removeAttr('disabled');
				$('#bigShirt').attr("src","img/shirts/"+$('#id').val()+"-big.png");
				$('#dispo').html("En stock");
			}
			else
			{
				$('#bigShirt').attr("src","img/shirts/rupture/"+$('#id').val()+"-big.png");
				$('#dispo').html("Rupture");
			}
		},
		
		error: function(jqXHR, textStatus, errorThrown) {
		}
	});

}

function buySelectedShirt()
{
	buyShirt($('#id').val(), 
		$('#color').val(), 
		($('#sexRadio').is(':checked'))?'H':'F',
		$('#size').val(),
		$('#quantity').val());
}
